<template>
  <div class="main">

  </div>
 
</template>

<script>
import { MessageReceiveService } from '../../service/Services.js'

export default {
  name: 'MessgeCenter',
  components: {
  },

  data () {
    return {
      pageData: {},
      documents: [],
      isInvited: false,
      isDocument: true
    }
  },
  methods: {
    loadData () {
      let providerGUID = this.$store.getters.getUserInfo.ProviderGUID
      let messgeGUID = this.$route.query.MsgGUID
      let me = this
      // 标志位已读
      MessageReceiveService.SetMessageHistoryAndGetMessage(providerGUID, messgeGUID).then((res) => {
        let item = res.Data[0]
          // 跳转
        let aryBm = ['待报名']
        if (aryBm.includes(item.Subject)) {
            // 跳转招标预告详情
            // 获取获取招标预告GUID
          let cgPlanGUID = item.Url.match(/[0-9a-f]{8}(-[0-9a-f]{4}){3}-[0-9a-f]{12}/gi)[0]
          MessageReceiveService.GetInviteBidForenoticeGUID(cgPlanGUID, providerGUID).then((res) => {
            let path = {path: '/demos/bid-forenotice-invited-detail',
              query: {InviteBidForenoticeGUID: res.Data[0].InviteBidForenoticeGUID, BmState: '报名中'}}
            me.$router.replace(path)
          })
          return
        }
           // 跳转到地铁图
        let aryDtType = ['入围结果通知', '定标结果通知', '发标维护', '待回标', '待下载标书', '下载标书补充文件', '发标情况变更通知']
        if (aryDtType.includes(item.Subject)) {
          let cgPlanGUID = item.Url.match(/[0-9a-f]{8}(-[0-9a-f]{4}){3}-[0-9a-f]{12}/gi)[0]
          MessageReceiveService.GetInviteBidGUID(cgPlanGUID, providerGUID).then((res) => {
            let path = {path: '/demos/my-invite-bid-detail',
              query: {InviteBidGUID: res.Data[0].InviteBidGUID,
                CgPlanGUID: cgPlanGUID,
                InviteBidForenoticeGUID: res.Data[0].InviteBidForenoticeGUID},
              replace: true}
            me.$router.replace(path)
          })
          return
        }
        // 跳转到答疑界面
        let aryAnswer = ['下载标书回复文档']
        if (aryAnswer.includes(item.Subject)) {
          let InviteBidGUID = item.Url.match(/[0-9a-f]{8}(-[0-9a-f]{4}){3}-[0-9a-f]{12}/gi)[0]
          MessageReceiveService.GetPlanGUIDByInviteBidGUID(InviteBidGUID, providerGUID).then((res) => {
            let path = {path: '/demos/invite-bid-question',
              query: {InviteBidGUID: InviteBidGUID,
                CgPlanGUID: res.Data[0].CgPlanGUID,
                InviteBidForenoticeGUID: res.Data[0].InviteBidForenoticeGUID},
              replace: true}
            me.$router.replace(path)
          })
          return
        }
        // 跳转到答疑界面
        let arySugest = ['待澄清']
        if (arySugest.includes(item.Subject)) {
          let guids = item.Url.match(/[0-9a-f]{8}(-[0-9a-f]{4}){3}-[0-9a-f]{12}/gi)
          let InviteBidGUID = guids[0]
          let inquiryGUID = guids[2]
          let path = {path: '/demos/invite-bid-ask-detail',
            query: {inviteBidGUID: InviteBidGUID, inquiryGUID: inquiryGUID}}
          me.$router.push(path)
        } else {
          let path = {path: '/demos/message-receive',
            query: {IsHistory: 1},
            replace: true}
          me.$router.replace(path)
        }
      })
    }
  },
  mounted () {
    this.loadData()
  }
}
</script>
